﻿<script src="@Url.Content("~/Scripts/jquery-1.6.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.signalR.min.js")" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content("~/signalr/hubs")"></script>

<div id='container'>
    <div id='gamescore'>
        <b>Live GameScores:</b>
        <br /><br />
        So, this being the backend server, I am assuming we have the latest Game Scores accessible. This is where you get to use whatever technique you want to have the latest scores; the point is what's in the fields below gets instantly updated on Windows Phones connected to our SignalR Hub. Same technique works for Stock-Tickers or other real-time information bits.
        <br /><br />
        <font color="red"><b>Team A:</b></font> &nbsp;&nbsp;
        <input type="text" id="teamAScore" maxlength="3" value="0" onkeypress="NumericOnly();" />
        <br /><br />
        <font color="red"><b>Team B:</b></font> &nbsp;&nbsp;
        <input type="text" id="teamBScore" maxlength="3" value="0" onkeypress="NumericOnly();" />
        <br /><br />               
    </div>   
</div>

<script type="text/javascript">    

    function NumericOnly() 
    {
        var key = window.event.keyCode;

        if ((key > 47 && key < 58))
            return;
        else
            window.event.returnValue = null;
    }

    $(function () 
    {
        // Create the connection to our SignalR GameScore Hub.
        var signalRGameScoreHub = $.connection.gameScoreHub;

        // Change event-handler for the Game Score textboxes.
        $('#teamAScore').change(function () 
        {
            // Call Server method.
            signalRGameScoreHub.pushScoresToClients($('#teamAScore').val(), $('#teamBScore').val());
        });

        $('#teamBScore').change(function () 
        {
            // Call Server method.
            signalRGameScoreHub.pushScoresToClients($('#teamAScore').val(), $('#teamBScore').val());
        });

        // Start the SignalR Hub.
        $.connection.hub.start(function () 
        {
            // Do stuff here, if needed.         
        });
    });

</script>